package com.qiku.controller;

import com.qiku.entity.Store;
import com.qiku.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private StoreService storeService;
    @GetMapping("/query")
    public List<Store> query(){
        List<Store> storeList = storeService.list();
        return storeList;
    }

    @GetMapping("/query/{id}")
    public Store queryById(@PathVariable Integer id){
        Store store = storeService.getById(id);
        return store;
    }

    /**
     * 根据id删除
     * @param id
     */
    @GetMapping("/removeById")
    public void removeById(@PathVariable Integer id){
        storeService.removeById(id);
    }

    /**
     * 保存或者修改
     * @param store
     */
    @PostMapping("/saveOrUpdate")
    public void saveOrUpdate(@RequestBody Store store){
        storeService.saveOrUpdate(store);
    }
}
